<script type="text/javascript" src="/js/epicrisis_ingresos.js"></script>

<div id="titulo_encabezado">
    <div style="padding: 5px;">
	<?php echo __('Registrar Nuevo Ingreso', true) ?>
    </div>
</div>

<div id="contenido_gral">
	
    <?php if($Pacientes){?>
        <h1>Seleccione si el paciente buscado corresponde con alguno de estos:</h1>			
    <?php } //endif Pacientes ?>
    
    <form action='/ingresos/paso1' method='post' id='frm_ingresos'>
        <h1>Si es un paciente nuevo, ingrese los datos del mismo:</h1>
            
            <table class='table' style='width:100%;'>
                <tr style='height:60px;'>
                    <td width="33%">
                        <div class="input text required">
                            <label for="name" class='label_grande'>1er. Nombre</label>
                            <input name="data[name]" type="text" value="<?php echo $data['name'];?>" id="name" class='input_grande' required>
                            <?php if(isset($errores['name'])){ echo $errores['name'];} ;?>
			</div>
                    </td>
                    <td width="33%">
		 	<div class="input text">
                            <label for="name2" class='label_grande'>2do. Nombre</label>
                            <input name="data[name2]" type="text" value="<?php echo $data['name2'];?>" id="name2" class='input_grande'>
			</div>
                    </td>
                    <td width="33%">
                        <div class="input text">
                            <label for="name3" class='label_grande'>Otros Nombres</label>
                            <input name="data[name3]" type="text" value="<?php echo $data['name3'];?>" id="name3" class='input_grande'>
			</div>
                    </td>
		</tr>	
		
                <tr style='height:60px;'>
                    <td>
		  	<div class="input text required">
                            <label for="lastname" class='label_grande'>1er. Apellido</label>
                            <input name="data[lastname]" type="text" value="<?php echo $data['lastname'];?>" id="lastname" class='input_grande' required>
                            <?php if(isset($errores['lastname'])){ echo $errores['lastname'];} ;?>
			</div>
                    </td>
                    <td>
		  	<div class="input text">
                            <label for="lastname2" class='label_grande'>2do. Apellido</label>
                            <input name="data[lastname2]" type="text" value="<?php echo $data['lastname2'];?>" id="lastname2" class='input_grande'>
			</div>
                    </td>
                    <td>
		  	<div class="input text">
                            <label for="lastname3" class='label_grande'>Otros Apellidos</label>
                            <input name="data[lastname3]" type="text" value="<?php echo $data['lastname3'];?>" id="lastname3" class='input_grande'>
			</div>
                    </td>
		</tr>	

		<tr style='height:60px;'>
                    <td>
                        <div class="input text">
                            <label for="gender" class='label_grande'>Género</label>
                            <?php echo $this->Form->input('gender_id',array(
			  					'type'=>'select',
			  					'options'=>$genders, 
			  					'label' => false,
			  					'empty' => '--- Seleccione uno ---'
			  					));
                            ?>
                            <?php if(isset($errores['gender_id'])){ echo $errores['gender_id'];} ;?>
			</div>
                    </td>
                    <td>
                        <div class="input text">
                            <label for="sex_id" class='label_grande'>Sexo</label>
                            <?php echo $this->Form->input('sex_id',array( 
			  					'label' => false, 
		  						'type'=>'select',
		  						'options'=>$sexes, 
								'empty' => '--- Seleccione uno ---')); 
                            ?>
                            <?php if(isset($errores['sex_id'])){ echo $errores['sex_id'];} ;?>
			</div>
                    </td>
                    <td>
                        <div class="input text">
                            <label for="fecha_nacimiento" class='label_grande'>Fecha de Nacimiento</label>
                            <select name='data[dia_nac]' style='width:60px;margin-right:4px;padding:4px;' required>
				<?php for($i=1;$i<=31;$i++){?>
                                    <?php $sel = ($i==date('d') ? 'selected' : '' );?>
                                    <option value='<?php echo $i;?>' <?php echo $sel;?> ><?php echo $i;?></option>
				<?php } //endfor?>
                            </select>
                            /
                            <select name='data[mes_nac]' style='width:60px;margin-right:4px;padding:4px;' required>
                                <?php for($i=1;$i<=12;$i++){?>
                                    <?php $sel = ($i==date('m') ? 'selected' : '' );?>
                                    <option value='<?php echo $i;?>' <?php echo $sel;?> ><?php echo $i;?></option>
				<?php } //endfor?>
                            </select>
                            /
                            <select name='data[ano_nac]' style='width:90px;margin-right:4px;padding:4px;' required>
                                <?php $hoy = date("Y"); $desde = $hoy-100;?>
				<?php for($i=$desde; $i<=$hoy; $i++){?>
                                    <?php $sel = ($i==$hoy ? 'selected' : '' );?>
                                    <option value='<?php echo $i;?>' <?php echo $sel;?> ><?php echo $i;?></option>
				<?php } //endfor?>
                            </select>
			</div>
                    </td>
		</tr>
                
		<tr style='height:60px;'>
                    <td>
			<div class="input text">
                            <label for="gruposanguineo_id" class='label_grande'>Grupo Sanguíneo</label>
                            <?php echo $this->Form->input('gruposanguineo_id',array( 
			  					'label' => false, 
		  						'type'=>'select',
		  						'options'=>$gruposanguineos, 
								'empty' => '--- Seleccione uno ---')); 
                            ?>
                            <?php if(isset($errores['gruposanguineo_id'])){ echo $errores['gruposanguineo_id'];} ;?>
                        </div>
                    </td>
                    
                    <td>
                        <div class="input text">
                            <label for="telefono" class='label_grande'>Telefono</label>
                            <input name="data[telefono]" type="text" value="<?php echo $data['telefono'];?>" id="telefono" class='input_grande'>
			</div>
                    </td>
                    <td>
		  	<div class="input text">
                            <label for="email" class='label_grande'>Email</label>
                            <input name="data[email]" type="text" value="<?php echo $data['email'];?>" id="email" class='input_grande'>
			</div>
                    </td>
		</tr>	

		<tr style='height:60px;'>
                    <td>
                        <div class="input text required">
                            <label for="direccion" class='label_grande'>Domicilio</label>
                            <input name="data[direccion]" type="text" value="<?php echo $data['direccion'];?>" id="domicilio" class='input_grande'>
                            <?php if(isset($errores['direccion'])){ echo $errores['direccion'];} ;?>
			</div>
                    </td>
                    <td>
		  	<div class="input text">
                            <label for="localidad" class='label_grande'>Localidad</label>
                            <input name="data[localidad]" type="text" value="<?php echo $data['localidad'];?>" id="localidad" class='input_grande'>
                            <?php if(isset($errores['localidad'])){ echo $errores['localidad'];} ;?>
			</div>
                    </td>
                    <td>
			<div class="input text">
                            <label for="provincia" class='label_grande'>Provincia</label>
                            <input name="data[provincia]" type="text" value="<?php echo $data['provincia'];?>" id="provincia" class='input_grande'>
                            <?php if(isset($errores['provincia'])){ echo $errores['provincia'];} ;?>
			</div>
                    </td>
		</tr>	

                <tr>
                    <td style='width:35%;padding:10px;'>
			<div class="input text">
                            <label for="Credencial" class='label_grande'>Nro.de Credencial</label>
                            <input name="data[credencial]" type="text" value="<?php echo $data['credencial'];?>" id="credencial" class='input_grande' required readonly>
                            <?php if(isset($errores['credencial'])){ echo $errores['credencial'];} ;?>
			</div>
                    </td>
                    <td style='width:35%;padding:10px;'>
			<div class="input text">
                            <label for="Documento" class='label_grande'>Tipo y Nro.de Documento</label>
                            <select name='data[typodocument]' style='width:100px;float:left;margin-right:4px;padding:4px;' required>
                                <?php foreach($Typodocuments as $typodocument){?>
                                    <option value='<?php echo $typodocument['Typodocument']['id'];?>'><?php echo $typodocument['Typodocument']['name'];?></option>
				<?php } //endforeach?>
                            </select>
                            <input name="data[documento]" type="text" value="<?php echo $data['documento'];?>" id="documento" class='input_grande' style='width:200px;'>
                            
                            <div class='ayuda_input'>Escriba el nro solamente. Ej:21497593</div>
                            <?php if(isset($errores['documento'])){ echo $errores['documento'];} ;?>
			</div>
                    </td>   
		</tr>	

		<tr>
                    <td colspan='3' style='padding-top:20px;text-align:right;'>
			<div class="input text">
                            <button type="submit" class='btn btn-primary' id='btn_enviar' style='width:220px;padding:10px;'>Guardar datos y asignar turno
                                <img src='/images/btn_loading.gif' id='enviando' style='display:none;margin-left:10px;'>
                            </button>
			</div>
                    </td>
		</tr>
	</table>

    </form>
</div>
<?php pr($data);?>